<h2 class="h2-title">Danh sách sản phẩm !!!</h2>

<p><a href="<?=base_url()?>backend/product/createproduct" class="bnt" style="margin-bottom: 15px;">Thêm sản phẩm</a></p>
<div style="clear: both;"></div>
<form style="margin-bottom: 20px;" enctype="multipart/form-data" action="<?=base_url()?>backend/product/import_from_csv" method="POST">
    <input style="margin-top: 20px;" type="file" name="csvfile"/>
    <input type="submit" value="IMPORT" class="bnt" id="csv" />
</form>

<script type="text/javascript">
    $("#csv").click(function(){

        var csv = $(this).parent().find('input[name=csvfile]').val();

        if(csv == '')
        {
            alert('Hãy nhập tên file import !');
            return false;
        }

    });
</script>
<div class="clear"></div>
<?php if($this->native_session->flashdata('msg')):?>
    <ul class="notification succ">
        <li class="notifi_img"><img src="<?=base_url()?>assets/backend/css/images/icons/tick_circle.png"/></li>

        <li class="msg"><?=$this->native_session->flashdata('msg')?></li>

        <li class="close"><img src="<?=base_url()?>assets/backend/css/images/icons/cross_grey_small.png"/></li>

    </ul><!--End of .notification -->
<?php endif?>

<table class="pretty">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Hình ảnh</th>
                            <th>Tên sản phẩm</th>
                            <th>Loại sản phẩm</th>
                            <th>Trạng thái</th>
                            <th>Nổi bật</th>
                            <th>Giá</th>
                            <th>Số lượng</th>
                            <th>Người tạo</th>
                            <th>Ngày tạo</th>
                            <th>Sửa</th>
                            <th>Xoá</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php if(isset($msg)):?>
                            <td colspan="11"><?= $msg ?></td>
                        <?php else:?>
                            <?php if(!empty($products)):?>
                                <?php $count = 0;?>
                                <?php foreach($products as $product):?>
                                    <tr>
                                        <td><?=$product->product_id?></td>
                                        <td><img style="border: 1px solid #ddd;" width="100px" height="60px" src="<?=base_url()?><?=$product->product_thumb?>" /></td>
                                        <td><?=$product->product_name?></td>
                                        <?php if(!empty($menus)):?>
                                            <?php foreach($menus as $menu):?>
                                                <?php if($menu->menu_id == $product->product_categories):?>
                                                    <td><?=$menu->menu_name?></td>
                                                    <?php break;?>
                                                <?php endif;?>
                                            <?php endforeach;?>
                                        <?php endif;?>
                                        <?php if($product->product_status == 1):?>
                                            <td>Hiển thị</td>
                                        <?php else:?>
                                            <td>Ẩn</td>
                                        <?php endif;?>
                                        <?php if($product->product_hightlight == 1):?>
                                            <td>Có</td>
                                        <?php else:?>
                                            <td>Không</td>
                                        <?php endif;?>
                                        <?php if($product->product_price_sale != 0):?>
                                            <td><?=number_format($product->product_price_sale,0,",",".")?> đ</td>
                                        <?php else:?>
                                            <td><?=number_format($product->product_price,0,",",".")?> đ</td>
                                        <?php endif;?>

                                        <td><?=$product->product_quantity?></td>
                                        <td><?=$product->product_user_created?></td>
                                        <td><?=$product->product_created?></td>
                                        <td>
                                            <a href="<?=base_url()?>backend/product/editproduct/<?=$product->product_id?>" class="edit">
                                                <img src="<?=base_url()?>assets/backend/css/images/edit.png"/>
                                            </a>
                                        </td>
                                        <td>
                                            <a href="<?=base_url()?>backend/product/delproduct/<?=$product->product_id?>" class="delete">
                                                <img  src="<?=base_url()?>assets/backend/css/images/delete.png"/>
                                            </a>
                                        </td>
                                    </tr>
                                    <?php unset($products[$count]);?>
                                    <?php $count++?>
                                <?php endforeach;?>
                            <?php endif;?>

                        <?php endif;?>
                    </tbody>
                </table>